<?php
allowCors();
if (!methodsRequired(['post'])) return;
if (!checkAdmin($msg)) return;

if (isset($_REQUEST['user_name']) && isset($_REQUEST['password'])) {
    $username = $_REQUEST['user_name'];
    $password = $_REQUEST['password'];
    $admin = new Admin($username, $password);
    if ($db->add($admin)) {
        $msg->setCode(0);
    } else {
        $msg->setCode(1);
    }
}else{
    $msg->setCode(1);
}

echo $msg;
